#include <stdio.h>
#include <unistd.h>
#include <string.h>

#define NUM 102
#define NONE "\e[0m"
#define RED "\e[;31m"
#define BLUE "\e[;34m"
#define YELLOW "\e[;33m"
int main()
{
  char bar[NUM];
  memset(bar,0,sizeof(bar));
  int count =0;
  const char *lable = "|/-\\";
  while(count <=100)
  {
    if(count >= 0 && count <= 20)
    {  
      printf(NONE"[%-100s][%d%%]%c\r"NONE,bar,count,lable[count%4]);
    }else if(count >20&& count <=40)
    {
      printf(RED"[%-100s][%d%%]%c\r"NONE,bar,count,lable[count%4]);
    }else if(count >40 && count <=60)
    {
      printf(BLUE"[%-100s][%d%%]%c\r"NONE,bar,count,lable[count%4]);
    }else{
      printf(YELLOW"[%-100s][%d%%]%c\r"NONE,bar,count,lable[count%4]);
    }
    bar[count++] = '#';
    fflush(stdout);
    usleep(30000);
  }
  printf("\n");
  return 0;
}
